<?php

class FormFrame extends FormControl {
	
	public function __construct() { 
		parent::__construct(array(
			'wbtype' => 'Frame',
			'x' => 0,
			'y' => 0,
			'width' => 100,
			'height' => 100,
			'caption' => 'frame'
		));
	}

	/**
	 * 컨트롤 그리기 
	 * 
	 * @param WBGraphics $graphics
	 */
	public function displayControl(WBGraphics $g) {

		$xstart = $this->getOption('x');
		$ystart = $this->getOption('y');
		$width = $this->getOption('width');
		$height = $this->getOption('height');		
		$xcenter = $xstart + $width / 2;
		$xend = $xstart + $width;
		$ymiddle = $ystart + $height / 2;
		$yend = $ystart + $height;	
	
		if (ProjectManager::$checkWireFrame->isChecked()) { 
			$pushbutton = new FormPushButton();
			$pushbutton['caption'] = $this['caption'];
			$pushbutton['x'] = $xstart;
			$pushbutton['y'] = $ystart;
			$pushbutton['width'] = $width;
			$pushbutton['height'] = $height;
			$pushbutton['style'] = $this['style'];
			
			$pushbutton->displayControl($g);
		} else { 
			
			if ($this->checkStyle('border')) { 
				$xend = $xstart + $width;
				$yend = $ystart + $height;
			
				if(ProjectManager::$checkWireFrame->isChecked()) {
					$g->rect($xstart, $ystart, $width, $height, FormControl::SHADE, false, 1, WBGraphics::LINE_DASHES_2);
				} else {
					$color = ($this->checkStyle('disabled readonly')) ? FormControl::DISABLED : FormControl::EDIT;
					
					$g->rect($xstart, $ystart, $width, $height, $color, true);
					$g->line($xend - 2, $ystart, $xend - 2, $yend - 2, FormControl::EDITSHADE);
					$g->line($xstart, $yend - 2, $xend - 2, $yend - 2, FormControl::EDITSHADE);
					$g->line($xstart, $ystart, $xend - 2, $ystart, FormControl::SHADOW);
					$g->line($xstart, $ystart, $xstart, $yend - 2, FormControl::SHADOW);
				}
			} else { 
				$color = ($this->checkStyle('disabled')) ? FormControl::DISABLED : FormControl::EDIT;
				$g->rect($xstart, $ystart, $width, $height, $color, true);
			}
		}

	
		// Draw image
		if (!ProjectManager::$checkWireFrame->isChecked()) { 
			$g->image(self::$draw_htmlcontrol, $xstart + 2, $ystart + 2, $width - 20, $height - 4);
		}
		
		$scrollbar = new FormScrollBar();
		$scrollbar['caption'] = $this['caption'];
		$scrollbar['x'] =  $xstart + $width - 19;
		$scrollbar['y'] = $ystart + 1;
		$scrollbar['width'] = 18;
		$scrollbar['height'] = $height - 2;
		$scrollbar['style'] = $this['style'];
		$scrollbar['style'] = $this['value'];
		
		$scrollbar->displayControl($g);		

	}
}


?>